<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Activity;
use Illuminate\Support\Carbon;
use App\Models\ActivityPrize;

class ActivityPrizeSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $activity_ids = Activity::all()->pluck('id')->toArray();
        $now = Carbon::now();
        foreach($activity_ids as $id){
            $rows = ActivityPrize::factory()->times(8)->make()->each(function ($row,$index) use ($now,$id){
                $row->activity_id = $id;
                $row->created_at = $now;
                $row->updated_at = $now;
            });
            ActivityPrize::insert($rows->toArray());
        }
        print("插入完成 \n");
    }
}
